Skip to content

fix(locale): weight common chinese surnames more frequently#3467

Draft
matthewmayer wants to merge 4 commits intofaker-js:nextfrom
matthewmayer:chinese-common-surnames
Draft

fix(locale): weight common chinese surnames more frequently#3467
matthewmayer wants to merge 4 commits intofaker-js:nextfrom
matthewmayer:chinese-common-surnames

Conversation

@matthewmayer
Copy link
Copy Markdown
Contributor

POC to fix #3466

Weights 20 common Chinese surnames to appear 80% of the time

@matthewmayer matthewmayer requested a review from a team as a code owner April 6, 2025 11:27
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 6, 2025

Deploy Preview for fakerjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 2d3cf1a
🔍 Latest deploy log https://app.netlify.com/projects/fakerjs/deploys/69d3edbce67fab00080b35a6
😎 Deploy Preview https://deploy-preview-3467.fakerjs.dev
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.89%. Comparing base (eba7d99) to head (2d3cf1a).

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #3467   +/-   ##
=======================================
  Coverage   98.89%   98.89%           
=======================================
  Files         887      887           
  Lines        3064     3064           
  Branches      556      556           
=======================================
  Hits         3030     3030           
  Misses         30       30           
  Partials        4        4           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@xDivisionByZerox xDivisionByZerox added c: bug Something isn't working p: 1-normal Nothing urgent c: locale Permutes locale definitions m: person Something is referring to the person module labels Apr 11, 2025
@xDivisionByZerox xDivisionByZerox added this to the vAnytime milestone Apr 11, 2025
@@ -1,4 +1,26 @@
export default {
generic_common: [
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this extra key as it is not included in the module definitions type contract. I'd be in favor to allow (not enforce!) weighted lists in the name schemas in general. I could see this being introduced as a workaround at most for now.

@yyz945947732
Copy link
Copy Markdown
Contributor

yyz945947732 commented Apr 14, 2025

zh_TW (Taiwan) also only includes a subset of common surnames, and it works quite well. so I think zh_CN could do the same — weighting may not be necessary (consider generic_common is not a module type). just removing the rare surnames and keeping the common ones might be enough.

If you're aligned with this idea, I'm happy to submit a PR for the change (pick surnames), which would only change the locals.

@matthewmayer
Copy link
Copy Markdown
Contributor Author

I'm not 100% sure this is the best approach (versus just using common surnames) though I'd say the fact that generic_common is not in the module definition is not enough to disqualify it as an approach, there are plenty of other edge cases in the locales which use non-standard keys.

For example company.legal_entity_type and company.category used in various definitions and locales.

@ST-DDT
Copy link
Copy Markdown
Member

ST-DDT commented Apr 6, 2026

For me, both weighting and/or reducing the number of rare last names in that list are valid sulutions.

@ST-DDT
Copy link
Copy Markdown
Member

ST-DDT commented Apr 6, 2026

Looks like you have to run preflight on this PR once more.

@ST-DDT ST-DDT marked this pull request as draft April 8, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: bug Something isn't working c: locale Permutes locale definitions m: person Something is referring to the person module p: 1-normal Nothing urgent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

using "common last_name" when generate chinese name

5 participants